<?php
use Illuminate\Http\Request;
/*
 * |--------------------------------------------------------------------------
 * | Application Routes
 * |--------------------------------------------------------------------------
 * |
 * | Here is where you can register all of the routes for an application with dingo.
 * | It is a breeze. Simply tell Lumen the URIs it should respond to
 * | and give it the Closure to call when that URI is requested.
 * |
 */
$api = app ( 'Dingo\Api\Routing\Router' );

$api->version ( 'v1', ['namespace' => 'App\Http\Controllers', 'middleware' => ['cors']], function ($api) {
	
	$api->group ( ['namespace' => 'v1','middleware' => 'jwt.auth'], function ($api) {
		// 认证
		$api->post ( 'auth/loginout', 'AuthController@loginout' );
		$api->post ( 'auth/refresh', 'AuthController@refresh' );
		$api->post ( 'auth/invalidate', 'AuthController@invalidate' );
		$api->get ( 'auth/vertify', 'AuthController@vertify' );
		
		//用户信息
		$api->get ( 'users/query/{uid?}', 'UserController@query' );
		$api->get ( 'users/current', 'UserController@current' );
		$api->post ( 'users/add', 'UserController@add' );
		$api->post ( 'users/delete', 'UserController@delete' );
		$api->post ( 'users/update', 'UserController@update' );
		
		//设备信息
		$api->get ( 'devices/query/{device_no}', 'DeviceController@query' );
		$api->get ( 'devices/list/{uid}', 'DeviceController@queryList' );
		$api->post ( 'devices/add', 'DeviceController@add' );
		$api->post ( 'devices/delete', 'DeviceController@delete' );
		$api->post ( 'devices/update', 'DeviceController@update' );
		
		//监测数据
		$api->post ( 'monitor/upload', 'MonitorController@upload' );
		$api->get ( 'monitor/download/{device_no}/{start_date}/{end_date}', 'MonitorController@download' );
		$api->get ( 'monitor/download/latest/{device_no}', 'MonitorController@downloadLatest' );
		$api->get ( 'monitor/download_danger/{device_no}/{start_date}/{end_date}/{marked}', 'MonitorController@downloadDanger' );
		$api->get ( 'monitor/download_user_danger/{start_date}/{end_date}', 'MonitorController@downloadUserDanger' );
		$api->post ( 'monitor/marked', 'MonitorController@marked' );
		$api->get ( 'monitor/notify', 'MonitorController@notify' );
		
		//获取菜单信息
		$api->get ( 'menu/download', 'MenuController@downloadMenu' );
		
		//options
		$api->options ( 'users/add', 'UserController@add' );
		$api->options ( 'users/delete', 'UserController@delete' );
		$api->options ( 'users/update', 'UserController@update' );
		$api->options ( 'devices/add', 'DeviceController@add' );
		$api->options ( 'devices/delete', 'DeviceController@delete' );
		$api->options ( 'devices/update', 'DeviceController@update' );
		$api->options ( 'monitor/upload', 'MonitorController@upload' );
		$api->options ( 'monitor/marked', 'MonitorController@marked' );
		
	} );
	
	$api->group ( ['namespace' => 'v1'], function ($api) {
		// 认证
		$api->get ( 'auth/token', 'AuthController@token' );
		
	} );
} );


